﻿using System;
using AMM.Model;
using AMM.Model.Project;

namespace AMM.UserControls {
    public partial class BOMSearchControl : BaseSearchControl {

        public override BaseSearchModel GetSearchModel() {
            int statusValue = Convert.ToInt32(this.cmbStatus.SelectedValue);

            BOMSearchModel searchResult = new BOMSearchModel();
            searchResult.Code = this.tbCode.Text;
            searchResult.MaterialCode = this.tbMaterialCode.Text;
            searchResult.CreateDateStart = this.GetDateTimePickerValue(this.dtpCreateStart);
            searchResult.CreateDateEnd = this.GetDateTimePickerValue(this.dtpCreateEnd);
            searchResult.BOMStatus = statusValue;

            if (statusValue == -1) { searchResult.BOMStatus = null; }

            return searchResult;
        }

        public override void ResetSearchModel() {
            this.tbCode.Clear();
            this.tbMaterialCode.Clear();
            this.dtpCreateStart.Checked = false;
            this.dtpCreateEnd.Checked = false;
            this.cmbStatus.SelectedIndex = 0;
        }

        public BOMSearchControl() {
            this.InitializeComponent();

            this.BindIsEnabled(this.cmbIsEnabled);
            this.BindAuditStatus(this.cmbStatus);
        }
    }
}
